<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="0">
    <link rel="stylesheet" href="../layui/css/layui.css?v=1" media="all">
    <script src="../js/jquery/1.x/jquery.js?v=1"></script>
    <script src="../layui/layui.js?v=1" charset="utf-8"></script>
    <script src="../js/config.js?v=1"></script>
    <script src="../js/public.js?v=1"></script>
    <script src="../js/function.js?v=1"></script>
    <script src="../js/echarts-en.common.js?v=1"></script>
    <link rel="stylesheet" href="../css/public.css?v=1">
    <link rel="stylesheet" href="../css/tongji.css?v=1">
</head>
<body>
<div class="container">
    <div class="search-box">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this">垂体各疾病占比</li>
                <li>年龄占比</li>
                <li>既往病史占比</li>
                <li>管理人数</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div id="pituitary" style="height: 650px;width: 1100px"></div>
                    <div class="tab-tips">
                        <div class="rule-title"><p>规则说明</p></div>
                        <div class="rule-info"><p>本中心垂体各疾病占比</p></div>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div id="age" style="height: 650px;width: 1100px"></div>
                    <div class="tab-tips">
                        <div class="rule-title"><p>规则说明</p></div>
                        <div class="rule-info">
                            <p>本中心管理患者的年龄性别分布情况</p>
                            <p>年龄分布说明：均为包含下限年龄，不包含上限年龄</p>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div id="illness" style="height: 650px;width: 1100px"></div>
                    <div class="tab-tips">
                        <div class="rule-title"><p>规则说明</p></div>
                        <div class="rule-info">
                            <p>本中心管理患者患有代谢疾病的占比</p>
                            <p>每种病的占比，仅在已填该病问题的人群中计算。</p>
                            <p>例：肿瘤占比=病史选了有肿瘤的患者数/病史中，做了“是否有肿瘤史”这道题的患者数</p>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div id="manager" style="height: 650px;width: 1100px"></div>
                    <div class="tab-tips">
                        <div class="rule-title"><p>规则说明</p></div>
                        <div class="rule-info">
                            <p>本院管理人数：本中心管理的患者总数</p>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    $(document).ready(function () {
        var height = $(window).height() - 2;
        //$('.container').height(height);
        //$('.search-box').height(height - 40);
        layui.use(['element', 'form', 'layer', 'laydate', 'laypage'], function () {
            var element = layui.element;
            var form = layui.form;
            var layer = layui.layer;
            var laydate = layui.laydate;
            var laypage = layui.laypage;
            var manAgeProportion = new Array();
            var womanAgeProportion = new Array();
            var pituitaryPercentKey = ['无功能瘤', 'GH瘤', 'PRL瘤', 'ACTH瘤', 'TSH瘤','GnH瘤（FSH/LH瘤）'];
            var pituitaryPercentValue = [];
            var illnessProportion = [];
            var managerUserDate = [];
            var managerUser = [];
            var managerUserSum = [];
            //垂体各疾病占比获取
            ajax_get(configUrl.pituitaryPercent,{hosp_id:getLocalStorage('hosp_id'),dept_id:getLocalStorage('dept_id')},(res)=>{
                var i = 0
                $.each(res.data,function (index,pituitary) {
                    pituitaryPercentValue[i] = {value:pituitary,name:pituitaryPercentKey[i]}
                    i++
                })
                var pituitaryChart = echarts.init(document.getElementById('pituitary'));
                var pituitaryOption = {
                    color:['#ff8833','#ffd966','#ff8c80','#7ed321','#61a7ff','#ffb44c',],
                    tooltip: {
                        trigger: 'item',
                        formatter: '{b} : {c} ({d}%)'
                    },
                    legend: {
                        orient: 'vertical',
                        left: 'left',
                        data: pituitaryPercentKey
                    },
                    series: [
                        {
                            name: '访问来源',
                            type: 'pie',
                            radius: '55%',
                            center: ['50%', '60%'],
                            data: pituitaryPercentValue,
                            emphasis: {
                                itemStyle: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                };
                pituitaryChart.setOption(pituitaryOption);
            })
            //年龄占比
            ajax_get(configUrl.ageProportion,{hosp_id:getLocalStorage('hosp_id'),dept_id:getLocalStorage('dept_id')},(res)=>{
                $.each(res.data,function (index,age) {
                    manAgeProportion.push(age.man);
                    womanAgeProportion.push(age.woman);
                })
                var ageChart = echarts.init(document.getElementById('age'));
                var ageOption = {
                    color: ['#51aaee','#ffb44c'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                            type: 'line'        // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    legend: {
                        data: ['男', '女' ],
                        bottom:0
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '10%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: ['30岁以下', '30-40岁', '40-50岁', '50-55岁', '55-60岁', '60-65岁', '65岁以上']
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            name:'人数'
                        }
                    ],
                    series: [
                        {
                            name: '男',
                            type: 'bar',
                            stack: '30以下',
                            data: manAgeProportion
                        },
                        {
                            name: '女',
                            type: 'bar',
                            stack: '30以下',
                            data: womanAgeProportion
                        },
                    ]
                };
                ageChart.setOption(ageOption);
            })
            //既往病史占比
            ajax_get(configUrl.illnessProportion,{hosp_id:getLocalStorage('hosp_id'),dept_id:getLocalStorage('dept_id')},(res)=>{
                console.log(res.data);
                $.each(res.data,function (index,illness) {
                    illnessProportion.push(illness);
                })
                var illnessChart = echarts.init(document.getElementById('illness'));
                var illnessOption = {
                    color:['#ffb44c'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        },
                        formatter: '{b} : {c}%'
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'value',
                        name:'%'
                    },
                    yAxis: {
                        type: 'category',
                        data: ['糖尿病','高血压','高血脂','骨质疏松','心脑血管事件','恶性肿瘤','慢性肾脏疾病','呼吸系统疾病','阻塞性睡眠呼吸暂停低通气综合征','慢性肝脏疾病','感染性疾病']
                    },
                    series: [
                        {
                            name: '2012年',
                            type: 'bar',
                            data: illnessProportion
                        }
                    ]
                };
                illnessChart.setOption(illnessOption);
            })
            //管理人数
            ajax_get(configUrl.managerUser,{hosp_id:getLocalStorage('hosp_id'),dept_id:getLocalStorage('dept_id')},(res)=>{
                $.each(res.data,function (index,manager) {
                    managerUserDate.push(index);
                    managerUser.push(manager.month);
                    managerUserSum.push(manager.month_sum);
                })
                var managerChart = echarts.init(document.getElementById('manager'));
                var managerOption = {
                    color: ['#51aaee','#ffb44c'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            label: {
                                backgroundColor: '#ff8c80'
                            }
                        }
                    },
                    legend: {
                        data: ['每月总人数', '每月新增人数'],
                        bottom:0,
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '10%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: managerUserDate
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            name: '每月新增人数',
                            type: 'line',
                            areaStyle: {},
                            data: managerUser
                        },
                        {
                            name: '每月总人数',
                            type: 'line',
                            areaStyle: {},
                            data: managerUserSum
                        }
                    ]
                };
                managerChart.setOption(managerOption);
            })

        })
    })



</script>
</html>